package com.kang.bean;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 自定义的Token对象
 * 在web应用中经常使用JWT(Json Web Token)作为token的工具
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AccessToken {

    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long expire;

    public AccessToken(Long userId){
        //默认过期时间12小时
        this(userId,System.currentTimeMillis()+1000 * 60 *60 * 12);
    }
}
